home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2322 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.5 KB

  1. Path: oxy.rust.net!usenet
  2. From: ebennett@rust.net
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: BC45, using a function in another project.
  5. Date: Wed, 17 Jan 1996 05:58:18 GMT
  6. Organization: Rust Net - High Speed Internet in Detroit  810-642-2276
  7. Message-ID: <4dhoir$ioj@oxy.rust.net>
  8. References: <4dfa06$eui@newsserver.trl.OZ.AU>
  9. NNTP-Posting-Host: liv-10.rust.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. t.hand@trl.oz.au (Trevor Hand) wrote:
  13.  
  14. >I am building a group of general functions which are
  15. >stored in a file called "MyUtils\GenUtil.cpp".  How do I
  16. >declare each function so that they are available to another
  17. >file in another directory, ie. they have global access, so
  18. >they can be used by other projects. eg.
  19.  
  20. >------------------------------
  21. >\MyUtils\GenUtil.cpp -
  22. >my collection of functions
  23.  
  24. >int MyGeneralVariable;
  25.  
  26. >void MyGeneralFunction(){
  27. >  //Does something usefull
  28. >  };
  29. >------------------------------
  30.  
  31. >------------------------------
  32. >\Programs\MyApp.cpp
  33. >#include "GenUtil.h" //I have set Project/Options to include a
  34. >//path to MyUtils.  A node to GenUtil.cpp is added to the IDE file.
  35. >:
  36. >:
  37. >MyGeneralFunction();//Linker says MyGeneralFunction is undefined
  38. >i = MyGeneralVariable;//I also want to use a variable from GenUtil.
  39. >:
  40.  
  41. I do not see anything wrong with what has been described here.  The
  42. only thing that I can think of is if the prototype for
  43. MyGeneralFunction() in GenUtil.h is not exactly identical to its
  44. declaration in GenUtil.cpp, the linker will not be able to match them
  45. up.
  46.  
  47. Earl
  48.  
  49.  
  50.